<?php

namespace Encore\WangEditorPro\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class WangEditorProController extends Controller
{
    public function upload(Request $request)
    {
        if (!empty($request->file())) {
            $res = [];
            foreach ($request->file() as $file) {
                $path = 'images/'.date('Ymd');
                $res['data'][] = '/uploads/'.$file->store($path,'admin');
            }
            $res['errno'] = 0;
        } else {
            $res['errno'] = 1;
            $res['info'] = '上传控件出现错误！或者您未选择任何文件';
        }
        return json_encode($res);
    }
}